import {defineStore} from "pinia";
import {getHomeCategories, getHomeHouselist} from "@/service/modules/api_home";

export const useHomeStore = defineStore('home', {
    state: () => ({
        categories: [],
        housePage: 1,
        houseList: []
    }),
    getters: {},
    actions: {
        async fetchCategoriesData() {
            const {data} = await getHomeCategories();
            this.categories = data
        },
        async fetchHouselistData() {
            const {data} = await getHomeHouselist(this.housePage);
            console.log(data)
            this.houseList.push(...data)
            this.housePage++
        }
    }
});